<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
		  "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<!--
	
                 Springs On Rails
                 Copyright [2007] [Sunny Liu]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.	
-->
<beans>	
   <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="locations">
			<list>
				<!--
				<value>WEB-INF/mail.properties</value>
				-->
				<value>WEB-INF/jdbc.properties</value>
			</list>
		</property>
	</bean>
	<!-- Uncomment the following after you setup database and -->
	<!-- comment out the Mock DAO after you setup database and -->
	
	<!--
	<bean id="dataSource"  class="org.springframework.jndi.JndiObjectFactoryBean">
		<#noparse>
		<property name="jndiName" value="${jdbc.jndiName}"/>
		</#noparse>
		<property name="lookupOnStartup" value="true"/>
		<property name="cache" 	value="true"/>
		<property name="proxyInterface" value="javax.sql.DataSource"/>
   </bean>
   <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<#noparse>
  <property name="driverClassName" value="${jdbc.driverClassName}" />
  <property name="url" value="${jdbc.url}" />
  <property name="username" value="${jdbc.username}" />
  <property name="password" value="${jdbc.password}" />
</#noparse>
  </bean>  
   -->
   
  <!--
  
  <#if appConfig.ormType=="hibernate" >  
  <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="mappingResources">
      <list>
       <#list entities as entity> 
        <value>/${appConfig.outputPackageNameInFilePath}/model/mapping/${entity.javaName}.hbm.xml</value>
       </#list>
      </list>
    </property>
    <property name="hibernateProperties">
      <value>
        <#if appConfig.dbType=="oracle">
        	hibernate.dialect=org.hibernate.dialect.Oracle9Dialect
        <#elseif appConfig.dbType=="mysql">
        	hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
        <#elseif appConfig.dbType=="mssql">
        	hibernate.dialect=org.hibernate.dialect.SQLServerDialect
        <#elseif appConfig.dbType=="sybase">
        	hibernate.dialect=org.hibernate.dialect.SybaseDialect
        <#elseif appConfig.dbType=="db2">
        	hibernate.dialect=org.hibernate.dialect.DB2Dialect
        <#else>
        	hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
        </#if>
      </value>
    </property>
  </bean>
  <#list entities as entity>    
  <bean id="${entity.normalizedJavaName}DAO" class="${appConfig.outputPackageName}.dao.hibernate.${entity.javaName}DAOImpl">
      <property name="sessionFactory" ref="sessionFactory"/>
  </bean>     
   </#list>   
  <#else>
   <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
		<property name="configLocation" value="WEB-INF/sql-map-config.xml"/>
		<property name="dataSource" ref="dataSource"/>
  </bean>
  <#list entities as entity>    
  <bean id="${entity.normalizedJavaName}DAO" class="${appConfig.outputPackageName}.dao.ibatis.${entity.javaName}DAOImpl">
     <property name="sqlMapClient" ref="sqlMapClient"/>
  </bean>     
   </#list>
   </#if>   
   -->
  
   <#list entities as entity>    
  <bean id="${entity.normalizedJavaName}DAO" class="${appConfig.outputPackageName}.dao.mock.${entity.javaName}DAOImpl">
  </bean>     
   </#list>
  
   
 
 
    
  <!-- uncomment proper transaction management to enable transaction support -->
  <!--
  <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
     <property name="dataSource" ref="dataSource"/>
  </bean> 
   
   <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
			<property name="autodetectTransactionManager" value="false" />
	</bean>	
	
	<bean id="springTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
		abstract="true" autowire="no">
		<property name="transactionManager" ref="transactionManager"/>			
		<property name="target" ref="${appConfig.appJavaName?uncap_first}Service"/>		
		<property name="transactionAttributes">
			<props>
				<prop key="update*">PROPAGATION_REQUIRED, -org.springframework.dao.DataAccessException</prop>
				<prop key="add*">PROPAGATION_REQUIRED, -org.springframework.dao.DataAccessException</prop>
				<prop key="delete*">PROPAGATION_REQUIRED, -org.springframework.dao.DataAccessException</prop>
				<prop key="insert*">PROPAGATION_REQUIRED, -org.springframework.dao.DataAccessException</prop>
				<prop key="*">PROPAGATION_REQUIRED, readOnly, -org.springframework.dao.DataAccessException</prop>
			</props>
		</property>
	</bean>
  -->
   <!-- ========================= DAO DEFINITIONS: IBATIS IMPLEMENTATIONS ========================= -->
   
   
   
   <bean id="${appConfig.appJavaName?uncap_first}Service" class="${appConfig.outputPackageName}.service.${appConfig.appJavaName}ServiceImpl">
     <#list  entities as entity>	
		<property name="${entity.normalizedJavaName}DAO" ref="${entity.normalizedJavaName}DAO"/>		
	</#list>
  </bean>     

</beans>